﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Interviewer_InterviewerInformation : System.Web.UI.Page
{
    EmployeeMethord EM = new EmployeeMethord();
    string _ID ="";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) 
        {
            viewInfomation();
        }
        btnSave.Visible = false;
        txtAddress.Enabled = false;
        txtBirthOfDate.Enabled = false;
        txtEmail.Enabled = false;
        txtFullName.Enabled = false;
        txtPhone.Enabled = false;
        txtUserName.Enabled = false;
        btnCancel.Visible = false;
    }
    public void viewInfomation() {
        try
        {
            _ID = Session["User"].ToString();
            DataTable tb = EM.informationInterviewer(_ID.ToString());
            if (tb.Rows.Count > 0)
            {
                txtUserName.Text = tb.Rows[0]["InterViewerID"].ToString();
                txtFullName.Text = tb.Rows[0]["FullName"].ToString();
                txtAddress.Text = tb.Rows[0]["Address"].ToString();
                txtPhone.Text = tb.Rows[0]["Phone"].ToString();
                txtBirthOfDate.Text = tb.Rows[0]["BirthOfDate"].ToString().Substring(0, tb.Rows[0]["BirthOfDate"].ToString().IndexOf(" "));
                txtEmail.Text = tb.Rows[0]["EmailID"].ToString();
            }
        }
        catch (Exception ex)
        {
        }
       
       
    }
   
    protected void btnUpdate_Click(object sender, EventArgs e)
    {        
        btnSave.Visible = true;
        txtAddress.Enabled = true;
        txtBirthOfDate.Enabled = true;
        txtEmail.Enabled = true;
        txtFullName.Enabled = true;
        txtPhone.Enabled = true;
        txtUserName.Enabled = true;
        btnUpdate.Visible = false;
        btnCancel.Visible = true;
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtPhone.Text == null)
        {
            lblErors.Text += "Please Enter Phone";
        }
        if (txtFullName.Text == null)
        {
            lblErors.Text += "Please Enter FullName";
        }
        if (txtEmail.Text == null)
        {
            lblErors.Text += "Please Enter Email";
        }
        if (txtAddress.Text == null)
        {
            lblErors.Text += "Please Enter Address";
        }
        if (txtBirthOfDate.Text == null)
        {
            lblErors.Text += "Please Enter BirthOfDate";
        }
        try
        {
            bool check = EM.UpdateInterviewer(txtFullName.Text, txtAddress.Text, txtPhone.Text, Convert.ToDateTime(txtBirthOfDate.Text), txtEmail.Text, txtUserName.Text);
            if (check == true)
            {
                lblErors.Text = "Update Successfull";
            }
            else
            {
                lblErors.Text = "Update false";
            }
        }
        catch (Exception ex)
        {
            
            throw;
        }

        
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        btnSave.Visible = false;
        txtAddress.Enabled = false;
        txtBirthOfDate.Enabled = false;
        txtEmail.Enabled = false;
        txtFullName.Enabled = false;
        txtPhone.Enabled = false;
        txtUserName.Enabled = false;
        btnCancel.Visible = false;
        btnUpdate.Visible = true;
    }
}